<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="poitemplate.xhtml">
        <ui:define name="pageTitre">Projet Ter</ui:define>
        <ui:define name="contenuTitre">Projet Ter</ui:define>
        <ui:define name="content">
            <h:form  styleClass="jsfcrud_list_form">
                <h:inputHidden id="id" value="#{poiController.poi.id}" />
                <c:set var="id" value="#{poiController.poi.id}" />



                <h:outputText value="Type" />
                <h:selectOneMenu id="type" value="#{poiController.typeString}">
                    <f:selectItems value="#{poiController.types}"
                                   var="type"
                                   itemValue="#{type.name}"
                                   itemLabel="#{type.name}" />
                </h:selectOneMenu>
                <h:message for="type" />
                <br />

                <h:outputText value="Tag" />
                <h:selectOneMenu id="tag"  value="#{poiController.tagString}">
                    <c:choose>
                        <c:when test="${id==null||id==0}">
                            <f:selectItem itemValue="aucun" itemLabel="Aucun" />
                        </c:when>
                        <c:otherwise>
                             <f:selectItem itemValue="null" itemLabel="Ne pas modifier" />
                        </c:otherwise>
                    </c:choose>
                    <f:selectItems value="#{poiController.tags}"
                                   var="tag"
                                   itemValue="#{tag.id}"
                                   itemLabel="#{tag}" />
                </h:selectOneMenu>

                <br />

                <h:outputText value="Longitude" />
                <h:inputText id="longitude" value="#{poiController.poi.longitude}"
                             required="true"
                             requiredMessage="Longitude obligatoire">
                    <f:validateDoubleRange />
                </h:inputText>
                <h:message for="longitude" />

                <h:outputText value="Latitude" />
                <h:inputText id="latitude" value="#{poiController.poi.latitude}"
                             required="true" requiredMessage="Latitude obligatoire">
                    <f:validateDoubleRange />
                </h:inputText>
                <h:message for="latitude" />

                <h:outputText value="Altitude" />
                <h:inputText id="altitude" value="#{poiController.poi.altitude}"
                             required="true" requiredMessage="Altitude obligatoire" >
                    <f:validateDoubleRange />
                </h:inputText>
                <h:message for="altitude" />

                <h:outputText value="Nom" />
                <h:inputText id="name" value="#{poiController.poi.name}"
                             required="true" requiredMessage="Nom obligatoire" />
                <h:message for="name" />

                <h:outputText value="Description" />
                <h:inputText id="description" value="#{poiController.poi.description}"
                             required="true" requiredMessage="Description obligatoire" />
                <h:message for="description" />

                <h:outputText value="Lien (Si plusieurs liens séparer les par des espaces)" />
                <h:inputText id="link" value="#{poiController.poi.link}"
                             required="true" requiredMessage="Lien obligatoire" />
                <h:message for="link" />

                <h:outputText value="Detail Action" />
                <h:inputText id="detailAction" value="#{poiController.poi.detailAction}"
                             required="true" requiredMessage="Detail Action obligatoire" />
                <h:message for="detailAction" />

                <h:outputText value="La resource icone" />
                <h:inputText id="iconResource" value="#{poiController.poi.iconResource}"
                             required="true" requiredMessage="La resource icone obligatoire" />
                <h:message for="iconResource" />

                <h:outputText value="Uri de l'icone" />
                <h:inputText id="iconUri" value="#{poiController.poi.iconUri}"
                             required="true" requiredMessage="Uri obligatoire" />
                <h:message for="iconUri" />

                <c:choose>
                    <c:when test="${id==null||id==0}">
                        <h:commandButton action="#{poiController.add}" value="Ajouter" />
                    </c:when>
                    <c:otherwise>
                        <h:commandButton action="#{poiController.update}" value="Modifier" />
                    </c:otherwise>
                </c:choose>
            </h:form>
        </ui:define>
    </ui:composition>
</html>